importPackage(net.sf.odinms.client);

var townmaps = Array(120000000, 680000000, 230000000, 101000000, 211000000, 100000000, 251000000, 103000000, 222000000, 104000000, 240000000, 220000000, 250000000, 800000000, 600000000, 221000000, 200000000, 102000000, 540000000, 801000000, 105040300); // Amherst, Amoria, Aquarium, Ellinia, El Nath, Henesys, Herb Town, Kerning City, Korean Folk Town, Leafre, Lith Harbor, Ludibrium, Mu Lung, Mushroom Shrine, New Leaf City, Omega Sector, Orbis, Perion, Showa Town, Sleepywood, Southperry
var status = 0;
var prize = 100;
var chosen = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("See you next time!.");
			cm.dispose();
			return;                    
		}
		if (mode == 1) {
			status++;
		} else {
			status--;
		}
		if (status == 0) {
			cm.sendYesNo("Hello there #b" + cm.getChar().getName() + "#k, I am hired to take you somewhere else\r\nDo you want to leave this place?");                  
		} else if (status == 1) {
			var selStr = "Select your destination.#b";
			for (var i = 0; i < townmaps.length; i++) {
				selStr += "\r\n#L" + i + "##m" + townmaps[i] + "# (#b" + prize + "#k mesos)";
			}
			cm.sendSimple(selStr);
		} else if (status == 2) {
			cm.sendYesNo("Do you want to go to #m" + townmaps[selection] + "# for #b" + prize + "#k mesos?");
			chosen = selection;
		} else {
			if (cm.getChar().getMeso() >= prize) {
				cm.warp(townmaps[chosen], 0);
				cm.gainItem(2100067, -(cm.itemQuantity(2100067)));
				cm.gainMeso(-prize);
			} else {
				cm.sendOk("Sorry, but you don't have #b" + prize + "#k mesos");
			}
			cm.dispose();
		}
	}
}